﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    class CountOfOne
    {
        public CountOfOne()
        {
            long beforeSum = 1;
            for(long i=2;i<1000000;i++)
            {
                beforeSum += GetCountOfOne(i);
                Console.Out.WriteLine(i + " : " + beforeSum);
                if (i == beforeSum)
                {
                    Console.Out.WriteLine("value = " + i);
                    GetConsole.GetInt();
                }
            }
            GetConsole.GetInt();
        }
        public long GetCountOfOne(long n)
        {
            long newN = n;
            long beforeN = n;
            long countOfOne = 0;
            while (newN != 0)
            {
                newN = newN / 10;
                if ((beforeN - (newN * 10)) == 1)
                {
                    countOfOne++;
                }
                beforeN = newN;
            }
            return countOfOne;
        }
    }
}
